package MAP;

import java.util.HashMap;
import java.util.Map;
import java.util.function.BiConsumer;

/**
 * Date: 2023-04-19
 * Time: 15:46
 */
public class MapDemo4 {
    public static void main(String[] args) {
        // 创建Map集合
        Map<String,String> map = new HashMap<>();

        // 添加元素
        map.put("齐天大圣","孙悟空");
        map.put("鸡你太美","蔡徐坤");
        map.put("空你几哇","小日本");

        // 匿名内部类
        map.forEach(new BiConsumer<String, String>() {
            @Override
            public void accept(String key, String value) {
                System.out.println(key+" "+value);
            }
        });

        // Lambda 遍历
        map.forEach((key,value)-> System.out.println(key+" "+value));
    }
}
